<script setup>
import { inject, ref } from "vue";
// import stepsview from "../components/steps/steps.vue";
import { useCounterStore } from "@/stores/upgrade";
import { onLoad, onShow } from "@dcloudio/uni-app";
import { cardshare } from "@/services/user";

const type = ref("");
const cardobj = ref({});
const card_id = ref("");

onLoad((e) => {
  if (e.card_id) {
    card_id.value = e.card_id;
  } else {
    uni.navigateBack();
  }

  // type.value = e.type ? e.type : 1;
});
onShow(() => {
  mycardfun();
});

async function mycardfun() {
  let res = await cardshare({ card_id: card_id.value });
  if (res.code == 200) {
    cardobj.value = res.data;
  }
}

async function historyfun() {
  let res = await history();
  if (res.code == 200) {
  }
}

const ceartempfun = () => {
  uni.navigateTo({
    url: "/pages/mycard/cardcreate/index",
  });
};
</script>

<template>
  <view class="upgrade">
    <view class="mycard-info">
      <view class="info-bg">
        <image
          :src="cardobj.back_img ? cardobj.back_img : '../static/card-bg.png'"
          mode="widthFix"
        />
      </view>
      <view class="mycard-info_box">
        <view class="card_info">
          <view class="card_info_box">
            <view class="card_info_top">
              <view class="card_info_top_left">
                <view class="card_info_top_img">
                  <image :src="cardobj.head" mode="aspectFill" shape="circle" />
                </view>
                <view class="card_info_top_text">
                  <text>{{ cardobj.real_name || "---" }}</text>
                  <text>{{ cardobj.title || "---" }}</text>
                </view>
              </view>
              <view class="card_info_top_right">
                <image src="../static/card-icon.png" mode="widthFix" />
              </view>
            </view>

            <view class="card_info_middle">
              <view class="card_info_middle_list">
                <image src="../static/home-icon.png" mode="widthFix" />
                <text>{{ cardobj.company || "---" }}</text>
              </view>
              <view class="card_info_middle_list">
                <image src="../static/phone-icon.png" mode="widthFix" />
                <text>{{ cardobj.mobile || "---" }}</text>
              </view>
              <view class="card_info_middle_list">
                <image src="../static/weixin-icon.png" mode="widthFix" />
                <text>{{ cardobj.wechat || "---" }}</text>
              </view>
              <view class="card_info_middle_list">
                <image src="../static/address-icon.png" mode="widthFix" />
                <text class="address_text">{{ cardobj.address }}</text>
                <text class="address_click">(点击地址导航)</text>
              </view>
            </view>

            <view class="qr_code">
              <view class="qr_code_img">
                <image :src="cardobj.qrcode" mode="scaleToFill" />
              </view>
              <text>识别二维码，查看名片</text>
            </view>
          </view>
        </view>
      </view>
    </view>

    <!-- <view class="mycard-info" >
      <view class="mycard-info_box">
        <view class="card_info">
          <view class="card_info_box">
            <view class="card_info_top">
              <view class="card_info_top_left">
                <view class="card_info_top_img">
                  <image
                    src="@/static/team/shopkeeper/user-img.png"
                    mode="aspectFill"
                    shape="circle"
                  />
                </view>
                <view class="card_info_top_text">
                  <text>蓝小平</text>
                  <text>明松旺推广大使</text>
                </view>
              </view>
              <view class="card_info_top_right">
                <image src="../static/card-icon.png" mode="widthFix" />
              </view>
            </view>

            <view class="card_info_middle">
              <view class="card_info_middle_list">
                <image src="../static/home-icon.png" mode="widthFix" />
                <text>明松旺中草药灸创业平台</text>
              </view>
              <view class="card_info_middle_list">
                <image src="../static/phone-icon.png" mode="widthFix" />
                <text>13800138000</text>
              </view>
              <view class="card_info_middle_list">
                <image src="../static/weixin-icon.png" mode="widthFix" />
                <text>fengxiaoxiao0123</text>
              </view>
              <view class="card_info_middle_list">
                <image src="../static/address-icon.png" mode="widthFix" />
                <text class="address_text"
                  >广东省广州市番禺区秋天路12栋12号001室</text
                >
                <text class="address_click">(点击地址导航)</text>
              </view>
            </view>
          </view>
        </view>
      </view>
    </view> -->
  </view>
</template>

<style lang="scss" scoped>
@import "./index.scss";
</style>
